package cn.com.fuhuitong.main.cate.mode

import cn.com.fuhuitong.http.BaseAbstractManager
import cn.com.fuhuitong.http.ResponseSubscribeListener
import cn.com.fuhuitong.http.SubscribeListener
import cn.com.fuhuitong.main.cate.entity.CateChildResponse
import cn.com.fuhuitong.main.cate.entity.CateGroupResponse
import io.reactivex.Observable
import io.reactivex.disposables.Disposable

class CategoryManager : BaseAbstractManager<CategoryApi>(CategoryApi::class.java) {

    /**
     * 一级分类数据
     */
    fun cateGroup(
        listener: SubscribeListener<CateGroupResponse>
    ): Disposable {
        val cateGroup: Observable<CateGroupResponse> = apiService.cateGroup()
        return subscribe(cateGroup, ResponseSubscribeListener(listener))
    }

    /**
     * 二级分类数据
     */
    fun cateChild(
        id: Int, listener: SubscribeListener<CateChildResponse>
    ): Disposable {
        val cateChild: Observable<CateChildResponse> = apiService.cateChild(id.toString())
        return subscribe(cateChild, ResponseSubscribeListener(listener))
    }

}